<template>
  <div class="demo">
    <h1>学校名称:{{ name }}</h1>
    <h1>学校地址:{{ address }}</h1>
    <h1>学生姓名:{{ studentName }}</h1>
  </div>
</template>
<script>
export default {
  name: "School",
  data() {
    return {
      name: "B站大学",
      address: "家里蹲",
      studentName:''
    };
  },
  mounted() {
    this.$bus.$on('studentName',(name)=>{
      console.log('我是School组件收到了数据',name);
      this.studentName = name

    })
  },
  beforeDestroy() {
     this.$off('studentName')
  },
};
</script>

<style scoped>
.demo {
  background-color: blueviolet;
}
</style>